package cn.com.sbell.vss.monitor;

import cn.com.sbell.vss.monitor.getter.LinuxPerformanceDataGetter;
import cn.com.sbell.vss.monitor.getter.SolarisPerformanceDataGetter;

public class PerformanceDataGetterFactory {
	public static String getOsName() {
		String osName = System.getProperty("os.name");
		if (osName == null) {
			throw new NullPointerException("Can NOT get OS name!");
		}
		osName = osName.trim().toLowerCase().replace(' ', '_');
		return osName;
	}

	public static IPerformanceDataGetter getPerformanceDataGetter() {
		String osName = getOsName();
		return getPerformanceDataGetter(osName);
	}

	public static IPerformanceDataGetter getPerformanceDataGetter(String osName) {
		if ("sunos".equals(osName)) {
			return new SolarisPerformanceDataGetter();
		} else if ("linux".equals(osName)) {
			return new LinuxPerformanceDataGetter();
		}
		return null;
	}
}
